package com.xh.audit.vo.webform;

import com.mybatisflex.core.query.QueryWrapper;
import com.xh.audit.entity.project.AuditWorkpaper;
import lombok.Data;
import lombok.EqualsAndHashCode;

import static com.xh.audit.entity.project.table.AuditWorkpaperTableDef.AUDIT_WORKPAPER;
import static com.xh.audit.entity.project.table.ProjectTableDef.PROJECT;

@Data
@EqualsAndHashCode(callSuper = true)
public class AuditWorkpaperQuery extends PageParams<AuditWorkpaper> {
	private String workpaperCode;
	private String projectName;
	private Integer status;

	public QueryWrapper queryWrapperBuild() {
		QueryWrapper queryWrapper = QueryWrapper.create()
				.select(AUDIT_WORKPAPER.DEFAULT_COLUMNS,PROJECT.PROJECT_NAME)
				.from(AUDIT_WORKPAPER).innerJoin(PROJECT).on(AUDIT_WORKPAPER.PROJECT_ID.eq(PROJECT.ID))
				.and(AUDIT_WORKPAPER.WORKPAPER_CODE.eq(workpaperCode))
				.and(AUDIT_WORKPAPER.STATUS.eq(status))
				.and(PROJECT.PROJECT_NAME.likeLeft(projectName));
		return queryWrapper;
	}
}
